package com.naiterui.ehp.bs.cms.modules.user.feign;

import com.naiterui.ehp.bp.bo.esign.EsignNoSecretBO;
import com.naiterui.ehp.bp.bo.esign.PreSignResultBO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import com.naiterui.ehp.bp.support.config.FeignConfiguration;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

/**
 * @author guoyongxiang
 * @date 2019/12/4 14:14
 * @since 1.0.0
 */
@RequestMapping("inner/cms")
@FeignClient(name = "pharmacist", url = "${ehp.domain.pharmacist}", configuration = FeignConfiguration.class)
public interface PharmacisFeignClient {

    /**
     * 修改药师信息
     *
     */
    @PostMapping("user/update")
    Long update(@RequestBody String json) throws BusinessException;

    /**
     * 增加药师信息
     *
     * @param json
     */
    @PostMapping("user/add")
    Long add(@RequestBody String json) throws BusinessException;

    /**
     * 修改药师账号状态0正常 1禁用
     * @param pharmacistId
     * @param status
     * @throws BusinessException
     */
    @GetMapping("/user/{pharmacistId}/{status}")
    void accountStatus(@PathVariable("pharmacistId") Long pharmacistId,
                       @PathVariable("status")
                       @Max(value = 1, message = "状态不正确")
                       @Min(value = 0, message = "状态不正确") Integer status) throws BusinessException;

    /**
     * 获取药师免密状态
     * @param pharmacistId
     * @return
     * @throws BusinessException
     */
    @GetMapping("/user/getNoSecret")
    EsignNoSecretBO getNoSecretByPharmacistId(@RequestParam("pharmacistId") Long pharmacistId) throws BusinessException;

    /**
     * 处方单药师签名预签名
     * @param recomId
     * @param pharmacistId
     * @return
     */
    @PostMapping("/sign/pre")
    PreSignResultBO preSign(@RequestParam("recomId") Long recomId, @RequestParam("pharmacistId") Long pharmacistId) throws BusinessException;
}
